Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prosemirror-markdown

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prosemirror-markdown

ProseMirror Markdown integration

  • 1.13.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
553K
decreased by-52.24%
Maintainers
1
Weekly downloads
 
Created

What is prosemirror-markdown?

The prosemirror-markdown package provides tools to convert between ProseMirror's document model and Markdown. It allows you to parse Markdown into a ProseMirror document and serialize a ProseMirror document back into Markdown.

What are prosemirror-markdown's main functionalities?

Parsing Markdown to ProseMirror Document

This feature allows you to parse a Markdown string into a ProseMirror document. The code sample demonstrates how to use the defaultMarkdownParser to convert a Markdown string into a ProseMirror document.

const { schema } = require('prosemirror-schema-basic');
const { defaultMarkdownParser } = require('prosemirror-markdown');
const { DOMParser } = require('prosemirror-model');

const markdownText = '# Hello World\nThis is a paragraph.';
const doc = defaultMarkdownParser.parse(markdownText);
console.log(doc.toJSON());

Serializing ProseMirror Document to Markdown

This feature allows you to serialize a ProseMirror document back into a Markdown string. The code sample demonstrates how to use the defaultMarkdownSerializer to convert a ProseMirror document into a Markdown string.

const { schema } = require('prosemirror-schema-basic');
const { defaultMarkdownSerializer } = require('prosemirror-markdown');
const { Node } = require('prosemirror-model');

const doc = Node.fromJSON(schema, {
  type: 'doc',
  content: [
    { type: 'heading', attrs: { level: 1 }, content: [{ type: 'text', text: 'Hello World' }] },
    { type: 'paragraph', content: [{ type: 'text', text: 'This is a paragraph.' }] }
  ]
});
const markdownText = defaultMarkdownSerializer.serialize(doc);
console.log(markdownText);

Other packages similar to prosemirror-markdown

FAQs

Package last updated on 26 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc